#include "stdafx.h"
#include <stdlib.h> 
#include <iostream>
#include "orangeDuck.h"
#include "commonDuck.h"
#include "rubberDuck.h"
#include "tokenStream.h"
#include "interpreter.h"
#include <string>
#include <vector>
#include <assert.h>
using namespace std;

int main(int argc, char* argv[])
{
	string str = "";
	CBird * duck;
	
	cout << "Input type of bird(orange,common,rubber): ";
	cin >> str;
	while ( str != "orange" && str != "common" && str != "rubber" )
	{
		cout << "Bad type!!" << endl;
		cout << "Input type of bird(orange,common,rubber): ";
		cin >> str;
	}
	if ( str == "orange" )
		duck = new(COrangeDuck);
	if ( str == "common" )
		duck = new(CCommonDuck);
	if ( str == "rubber" )
		duck = new(CRubberDuck);
	str = "";
	cin.clear();
	cout << "let's have fun" << endl << endl;
	
	char c;
	while ( c = getchar() )
	{
		if ( c == '\n' && !str.empty()  )
		{
			CTokenStream tokenStream(str);

			vector<int> tokens = tokenStream.tokenaze();

			CInterpreter interptreter(tokens, duck);
			interptreter.interpret();
			
			str = "";
		}
		else
		{
			if ( c > 31 )
			{
				str += c;
			}
		}
	}
	return 0;
}
